package com.car.advertising.connection;

import android.app.Activity;
import android.text.TextUtils;
import android.widget.Toast;

import com.car.advertising.CarApplication;
import com.car.advertising.db.UserInfoBiz;
import com.car.advertising.entity.CarMsgEntiy;
import com.car.advertising.util.ObjectSaveUtil;
import com.car.advertising.util.PreferenceUtil;
import com.support.widget.util.ToastUtil;

/**
 * 开发者：LuoYi
 * Time: 2017 20:02 2017/5/2 05
 */

public class Contact {

    public static void LoginAgain(Activity context) {
//        JumpManager.gotoActivity(context, LoginActivity.class, false);
        ToastUtil.show(context, "您已退出登录", Toast.LENGTH_SHORT);
//        context.finish();
        removeToken();
        UserInfoBiz.getInstance(context).deleteAllInfo();
        removecarMsg(context);
    }

    public static void saveToken(String token) {
        PreferenceUtil.putString("token", token);
        CarApplication.token = token;
    }

    public static String readToken() {
        String token = PreferenceUtil.getString("token");
        if (!TextUtils.isEmpty(token)) {
            CarApplication.token = token;
        }
        return token;
    }

    public static void removeToken() {
        PreferenceUtil.removeString("token");
        CarApplication.token = "";
    }

    public static void saveCarMsg(Activity context, CarMsgEntiy carMsg) {
        ObjectSaveUtil.saveObject(context, "carMsg", carMsg);
    }

    public static void removecarMsg(Activity context) {
//        ObjectSaveUtil.saveObject(context, "carMsg", null);
    }

}
